package com.yanfan.parking.service.impl;

import java.util.Arrays;
import java.util.List;
import com.yanfan.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.parking.mapper.NjInParkingRecordMapper;
import com.yanfan.parking.domain.NjInParkingRecord;
import com.yanfan.parking.service.INjInParkingRecordService;

/**
 * 停车场进场记录Service业务层处理
 *
 * @author genluo
 * @date 2024-10-28
 */
@Service
public class NjInParkingRecordServiceImpl extends ServiceImpl<NjInParkingRecordMapper, NjInParkingRecord> implements INjInParkingRecordService {
    @Autowired
    private NjInParkingRecordMapper njInParkingRecordMapper;


    /**
     * 查询停车场进场记录列表
     *
     * @param njInParkingRecord 停车场进场记录
     * @return 停车场进场记录
     */
    @Override
    public List<NjInParkingRecord> queryPageList(NjInParkingRecord njInParkingRecord) {
        LambdaQueryWrapper<NjInParkingRecord> lqw = buildQueryWrapper(njInParkingRecord);
        return njInParkingRecordMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return njInParkingRecordMapper.queryPageList(njInParkingRecord);
    }

    /**
    * 分页查询条件
    * @return
    */
    private LambdaQueryWrapper<NjInParkingRecord> buildQueryWrapper(NjInParkingRecord bo) {
        LambdaQueryWrapper<NjInParkingRecord> lqw = Wrappers.lambdaQuery();
        lqw.eq(StringUtils.isNotBlank(bo.getActTime()), NjInParkingRecord::getActTime, bo.getActTime());
        lqw.eq(StringUtils.isNotBlank(bo.getActType()), NjInParkingRecord::getActType, bo.getActType());
        lqw.eq(StringUtils.isNotBlank(bo.getAddBerth()), NjInParkingRecord::getAddBerth, bo.getAddBerth());
        lqw.eq(StringUtils.isNotBlank(bo.getArriveTime()), NjInParkingRecord::getArriveTime, bo.getArriveTime());
        lqw.eq(StringUtils.isNotBlank(bo.getBerthId()), NjInParkingRecord::getBerthId, bo.getBerthId());
        lqw.eq(StringUtils.isNotBlank(bo.getBusinessType()), NjInParkingRecord::getBusinessType, bo.getBusinessType());
        lqw.eq(StringUtils.isNotBlank(bo.getCarNum()), NjInParkingRecord::getCarNum, bo.getCarNum());
        lqw.eq(StringUtils.isNotBlank(bo.getCarNumColor()), NjInParkingRecord::getCarNumColor, bo.getCarNumColor());
        lqw.eq(StringUtils.isNotBlank(bo.getCarType()), NjInParkingRecord::getCarType, bo.getCarType());
        lqw.eq(bo.getGuestRemainNum() != null, NjInParkingRecord::getGuestRemainNum, bo.getGuestRemainNum());
        lqw.eq(bo.getMonthlyRemainNum() != null, NjInParkingRecord::getMonthlyRemainNum, bo.getMonthlyRemainNum());
        lqw.eq(StringUtils.isNotBlank(bo.getParkingCarColor()), NjInParkingRecord::getParkingCarColor, bo.getParkingCarColor());
        lqw.eq(StringUtils.isNotBlank(bo.getParkingCarLogo()), NjInParkingRecord::getParkingCarLogo, bo.getParkingCarLogo());
        lqw.eq(StringUtils.isNotBlank(bo.getParkingCarType()), NjInParkingRecord::getParkingCarType, bo.getParkingCarType());
        lqw.eq(StringUtils.isNotBlank(bo.getParkingLot()), NjInParkingRecord::getParkingLot, bo.getParkingLot());
        lqw.eq(StringUtils.isNotBlank(bo.getSluiceDevChnId()), NjInParkingRecord::getSluiceDevChnId, bo.getSluiceDevChnId());
        lqw.like(StringUtils.isNotBlank(bo.getSluiceDevChnName()), NjInParkingRecord::getSluiceDevChnName, bo.getSluiceDevChnName());
        lqw.eq(bo.getTotRemainNum() != null, NjInParkingRecord::getTotRemainNum, bo.getTotRemainNum());
        lqw.eq(StringUtils.isNotBlank(bo.getVoucherType()), NjInParkingRecord::getVoucherType, bo.getVoucherType());
        lqw.orderByDesc(NjInParkingRecord :: getActTime);
        return lqw;
    }



}
